#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

using vec = vector<int>;

int find(vec &f, int x)
{
        return f[x] == x ? x : f[x] = find(f, f[x]);
}

int merge(vec &f, vec &s, int x, int y)
{
        int fx = find(f, x);
        int fy = find(f, y);
        if(fx != fy){
                f[fx] = fy;
                s[fy] += s[fx];
                return fy;
        }
        return 0;
}

int main()
{
        int n = 0;
        cin >> n;
        vector<vec> gh(n + 1);
        for(int i = 1, cnt = 0; i <= n; i++){
                cin >> cnt;
                for(int j = 0, v = 0; j < cnt; j++){
                        cin >> v;
                        gh[i].push_back(v);
                }
        }

        vec father(n + 1, 0);
        vec size(n + 1, 1);
        iota(father.begin(), father.end(), 0);

        for(int i = n; i>=1; i--){
                for(auto v : gh[i]){
                        if(v <= i){
                                continue;
                        }
                        int r = merge(father, size, v, i);
                        if(size[r] > n/2){
                                cout<<i<<endl;
                                return 0;
                        }
                }
        }
        return 0;
}